/**
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
"use strict";
define(["ojs/ojcore","jquery","ojs/ojcomponentcore"],function(a,g){(function(){a.Ra("oj.ojToolbar",g.oj.baseComponent,{widgetEventPrefix:"oj",options:{chroming:"half"},Yf:function(b,c){this._super(b,c);"disabled"in c&&a.t.warn("Caller attempted to set the 'disabled' option on Toolbar, but Toolbar does not support the 'disabled' option.  See API doc.")},_ComponentCreate:function(){this._super();this.element.attr(a.Components.po,this.widgetName).addClass("oj-toolbar oj-component").attr("role","toolbar");
this.ab(!0)},ph:function(a,c,d){a=this.element.find(":oj-button[tabindex\x3d0]");this.qh(c,d,{launcher:a,position:{of:"keyboard"===d?a.ojButton("widget"):c}})},_setOption:function(b,c){"disabled"===b?a.t.warn("Caller attempted to set the 'disabled' option on Toolbar, but Toolbar does not support the 'disabled' option.  See API doc.  Ignoring the call."):(this._superApply(arguments),"chroming"===b&&(this.CO.ojButtonset("refresh"),this.$_.ojButton("refresh")))},refresh:function(){this._super();this.ab(!1)},
ab:function(a){var c=this;this.jl="rtl"===this.nd();this.Df=this.element.find(":oj-button").unbind("keydown"+this.eventNamespace).bind("keydown"+this.eventNamespace,function(a){c.Ev(a,g(this))}).unbind("click"+this.eventNamespace).bind("click"+this.eventNamespace,function(){g(this).ojButton("option","disabled")||c.ow(g(this))}).unbind("focus"+this.eventNamespace).bind("focus"+this.eventNamespace,function(){c.ow(g(this))});this.CO=this.element.find(":oj-buttonset").ojButtonset("refresh");this.$_=this.Df.not(this.CO.find(":oj-button")).ojButton("refresh");
this.Vp=this.Df.filter(function(){return!g(this).ojButton("option","disabled")});this.YU(a)},YU:function(a){var c=g(this.Uv);this.Uv=void 0;this.Df.attr("tabindex","-1");a=a||!c.is(this.Vp)?this.Vp.first():c;this.ow(a)},yV:function(a){var c=this.Vp;return a.map(function(a,b){if("radio"!=b.type||b.checked||""==b.name)return b;var f=b.name;f?(f=f.replace(/'/g,"\\'"),f=c.filter(":radio[name\x3d'"+f+"']:oj-button")):f=c.filter(b).filter(":oj-button");f=f.filter(":checked");return f.length?f[0]:b})},ow:function(a){a=
this.yV(a);var c=a[0],d=this.Uv;c!==d&&(g(d).attr("tabindex","-1"),a.attr("tabindex","0"),this.Uv=c)},Ev:function(a,c){switch(a.which){case g.ui.keyCode.LEFT:case g.ui.keyCode.RIGHT:a.preventDefault();var d=this.Vp,e=d.length;if(2>e)break;var f=d.index(c);d.eq((f+(a.which==g.ui.keyCode.RIGHT^this.jl?1:-1)+e)%e).focus();break;case g.ui.keyCode.UP:case g.ui.keyCode.DOWN:"radio"==c.attr("type")&&a.preventDefault()}},_destroy:function(){this.element.removeClass("oj-toolbar oj-component").removeAttr(a.Components.po).removeAttr("role");
this.Df.attr("tabindex","0");this.CO.ojButtonset("refresh");this.$_.ojButton("refresh")}})})();a.Components.Wn({ojToolbar:{chroming:a.Components.Ne(function(){return(a.Wc.De("oj-toolbar-option-defaults")||{}).chroming})}});a.Components.Xa("ojToolbar","baseComponent",{properties:{chroming:{type:"string"},disabled:{}},methods:{destroy:{},refresh:{},widget:{}},extension:{_widgetName:"ojToolbar"}});a.Components.register("oj-toolbar",a.Components.getMetadata("ojToolbar"))});